]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
bluetooth: Name the device items for a11y
authorLukáš Tyrychtr <ltyrycht@redhat.com>
Tue, 24 Sep 2024 10:53:17 +0000 (12:53 +0200)
committerMarge Bot <marge-bot@gnome.org>
Wed, 16 Oct 2024 16:47:09 +0000 (16:47 +0000)
By doing that, they're finally announced by a screen reader.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3485>

js/ui/status/bluetooth.js

index 5d3581c423c4bcce10d1b1fea94114ae24dc7122..c1d6837a8bcbd398fdea04db59c94fbfc00a0efa 100644 (file)
@@ -247,6 +247,9 @@ class BluetoothDeviceItem extends PopupMenu.PopupBaseMenuItem {
 
         this.connect('destroy', () => (this._spinner = null));
         this.connect('activate', () => this._toggleConnected().catch(logError));
+        this._device.connect('notify::alias', () => this._updateAccessibleName());
+        this._device.connect('notify::connected', () => this._updateAccessibleName());
+        this._updateAccessibleName();
     }
 
     async _toggleConnected() {
@@ -254,6 +257,14 @@ class BluetoothDeviceItem extends PopupMenu.PopupBaseMenuItem {
         await this._client.toggleDevice(this._device);
         this._spinner?.stop();
     }
+
+    _updateAccessibleName() {
+        this.accessible_name = this._device.connected
+            // Translators: %s is a device name like "MyPhone"
+            ? _('Disconnect %s').format(this._device.alias)
+            // Translators: %s is a device name like "MyPhone"
+            : _('Connect to %s').format(this._device.alias);
+    }
 });
 
 const BluetoothToggle = GObject.registerClass(